package java6681.lesson07;

import java.io.File;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * @author Junichiro
 * @description
 * @date 2021-04-18 15:36
 **/

public class test {

    public static void main(String[] args) {
        File file = new File("F:\\IntelliJ IDEA 2020.2.1");

//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        String format = formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(file.lastModified()), ZoneId.of("Asia/Shanghai")));
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        File[] files = file.listFiles();
        int count = 0 ;
        int count1 = 1;

        for (File file1 : files) {
            if (file1.isDirectory()) {

                String format = formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(file1.lastModified()), ZoneId.of("Asia/Shanghai")));
                System.out.print("文件夹" + "，" + file1.getName() + ",     " + format + "\n");
                count++;
            }
        }
        System.out.println(count);
        for (File file1 : files) {
            if (file1.isFile()){
                String format = formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(file1.lastModified()), ZoneId.of("Asia/Shanghai")));
                System.out.println(file1.getName() + ",     " + format+","+(file1.length()/1024+1)+"KB");
                count1++;
            }
        }
        System.out.println(count1);

    }
}
